<?php 
if(!isset($_SESSION)) 
{ 
	session_start(); 
}
include 'connection/connection.php';
$username =  $_REQUEST['us'];
$password = $_REQUEST['ps'];
$action=$_REQUEST['ac'];
$kq='';
$query = mysql_query("SELECT cs.iUser,cs.szUser,cs.szPower FROM `caruser` cs WHERE cs.szUser ='".$username."' AND cs.szPasswd='".$password."'",$connection);
if(mysql_num_rows($query)>0){
	while ($row = mysql_fetch_array($query)){
		$_SESSION['iduser'] =  $row['iUser'];
		$_SESSION['usname'] =  $row['szUser'];
		$_SESSION['role'] = $row['szPower'];
		$_SESSION['activeaction']=$vaction;
	}
	$kq='l_loginok';
	$s='insert into loglogin (logDate,logTime,iUser,iMode) value(date(now()),time(now()),'.$_SESSION['iduser'].',0)';
	mysql_free_result($query);
	mysql_query($s,$connection);
}else{
	$kq='l_notlogin';
}
mysql_close($connection);
?>
<input type="hidden" id="idloi" value="<?=$kq?>"/><input type="hidden" id="idviewrole" value="<?=$_SESSION['role']?>"/><input type="hidden" value="<?=$_SESSION['iduser']?>" id="iduserlogin" />
